Skip to content

perf(client): stop replaying terminal buffers on rollover - #242

Merged
leoisadev1 merged 3 commits into
mainfrom
perf/client-terminal-incremental
Sep 14, 2026
Merged

perf(client): stop replaying terminal buffers on rollover#242
leoisadev1 merged 3 commits into
mainfrom
perf/client-terminal-incremental

Conversation

@leoisadev1

@leoisadev1 leoisadev1 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Problem

Terminal attach state stored one growing string and re-trimmed it on every output event. Clients then replayed the whole buffer into Ghostty or the native surface, which spikes on long sessions. The first incremental implementation also allowed a caught-up viewport to append after retained history rolled over, leaving discarded text visible.

Changes

Keep attach output as incremental UTF-8 chunks with a 512KiB retained bound and a cursor. Renderers append unread data and reset when the attach generation, explicit reset, or retained-output start changes. Each new attach stream gets a new generation so a stale cursor cannot append into the next session.

Mobile still materializes a string at the native surface boundary because the installed native view still takes initialBuffer.

Adapted from pingdotgg#9707. Akeru has no lifecycleVersion on the buffer state yet; snapshot and restart still reset output through resetOutput. Ghostty WASM snapshot tests from that PR were left out because this Vitest setup cannot load *.wasm?inline.

Verification

  • vp test run packages/client-runtime/src/state/terminalSession.test.ts apps/web/src/terminal/ghostty/core.test.ts apps/mobile/src/features/terminal/terminalMenu.test.ts apps/web/src/components/ThreadTerminalDrawer.test.ts: 39 passed.
  • Client runtime, web, and mobile typechecks passed.
  • Scoped lint, formatting, and git diff --check passed.

Native mobile terminal was not run on this Linux host.

Implemented and verified by GPT-5.6 Sol in T3 Code via the Codex harness.

Keep terminal attach output as incremental chunks with a 512KiB bound
and a cursor so renderers append instead of rewriting the whole buffer
on every event. Mobile still materializes a string at the native
surface boundary.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
akeru-bot-landing Skipped Skipped Sep 10, 2026 6:17pm UTC

Request Review

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

The terminal output state now maintains bounded UTF-8 chunk history and synchronizes each renderer safely after rollover, resets, and session changes. Web terminal surfaces pause while hidden and refit when shown, while mobile retains its legacy string boundary.

Confidence Score: 5/5

Safe to merge.

The previously reported rollover issue is fully addressed: readers now reset when their retained-output start offset differs from the current retained boundary, so they cannot append new output onto discarded terminal history.

Reviews (2): Last reviewed commit: "fix(client): reset terminal viewport aft..." | Re-trigger Greptile

Comment thread packages/client-runtime/src/state/terminalOutput.ts
@leoisadev1
leoisadev1 merged commit 1d98fd0 into main Sep 14, 2026
11 checks passed
@leoisadev1
leoisadev1 deleted the perf/client-terminal-incremental branch September 14, 2026 02:32
@github-actions github-actions Bot mentioned this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant